<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<%@include file="/WEB-INF/pages/include/prelude.jspf"%>
<%@include file="/WEB-INF/pages/include/common.jspf"%>
<link href="<c:url value='/static/css/memberInfo.css' />" type="text/css" rel="stylesheet"/>
<title>常用乘机人</title>
<script type="text/javascript">

$(function(){
   	$("#pagetitle").html('常用乘机人');
   	$("#pageback").hide();
});

function checkboxChange(){
		var customerIds = "";
		
		var count = 0;
		var aCount = 0;
		$("input:checkbox:checked").each(
			function(){
				var content = $(this).val().split("_");
				if(content[1]=='ADT'){
					aCount++;
				}
				count++;
 				customerIds = customerIds+content[0]+",";
			}
		);
		if(count>${count}){
			alert("请选择"+${count}+"位乘机人！");
			return;
		}
		
		if(count!=${count}){
			return;
		}else{
			if(${count==adultCount}){
				if(aCount!=${adultCount}){
					alert("请选择"+${adultCount}+"位成人!");
					return;
				}
			}else{
				if(${adultCount}!=aCount){
					if(${!empty childCount}){
						alert("请选择"+${adultCount}+"位成人,${childCount}位儿童！");
						return;
					}
				}
			}
			
			$("#customerIds").attr("value",customerIds);
			$("#formHidden").submit();	
		}
}

</script>
</head>
<body>
<div>
	<form id="formHidden" name="formHidden" action="<c:url value='/ticket/calculateTrip.do'/>" method="post" data-ajax="false" >
		<input type="hidden" name="searchId" value="${searchId }"  />
		<input type="hidden" name="index" value="${index }"  />
		<input type="hidden" name="count" value="${count }"  />
		<input type="hidden" id="customerIds" name="customerIds" value=""  />
		<input type="hidden" name="guestId" value="${guestId }"  />
		<input type="hidden" name="adultCount" value="${adultCount }" />
		<input type="hidden" name="childCount" value="${childCount }" />
	</form>
</div>


<div  data-role="page">
	<%@include file="/WEB-INF/pages/include/header.jsp"%>
	<div data-role="content">
		<br />
		<div class="take">
			<ul>
				<c:forEach items="${requestScope.customerList }" var="customer">
					<li>
						<div>
							<div class="i_mini_label_1"></div>
							<div class="i_mini_label">姓&nbsp;&nbsp;&nbsp;名：</div><b class="i_mini_label_2">
							<c:if test="${domestic=='' }">
								${customer.familyNameCn }${customer.firstNameCn }
							</c:if>
							<c:if test="${domestic=='1' }">
								${customer.firstNameEn }${customer.familyNameEn }
							</c:if>
							</b><div class="clear"></div>
							<div class="i_mini_label_1" style="position: relative;top: 15px; "><input name="chbox" type="checkbox" onchange="checkboxChange();" id="${customer.id }" value="${customer.id }_${customer.travelerType }" /> </div><div class="i_mini_label">证件类型：</div><b class="i_mini_label_2">
								<c:choose>
									<c:when test="${customer.certType=='2.DOC' }">
										护照
									</c:when>
									<c:when test="${customer.certType=='ID_CARD' }">
										身份证
									</c:when>
									<c:when test="${customer.certType=='MI_CARD' }">
										军官证或其他证件
									</c:when>
								</c:choose>
								</b>
								<a href="<c:url value='/member/customerEditUI.do' />?customerId=${customer.id }&odSerachId=${searchId }&odIndex=${index}&count=${count }&guestId=${guestId}&customerIds=${customerIds}&domestic=${domestic}&destinationCountry=${destinationCountry}&adultCount=${adultCount}&childCount=${childCount}" data-ajax="false" ><img alt="修改" width="25px;" src="<c:url value='/static/img/imgs/img_edit.png' />"></a>
								<a href="<c:url value='/member/customerDelete.do' />?customerId=${customer.id }&odSerachId=${searchId }&odIndex=${index}&count=${count }&guestId=${guestId}&customerIds=${customerIds}&domestic=${domestic}&destinationCountry=${destinationCountry}&adultCount=${adultCount}&childCount=${childCount}" data-ajax="false" ><img alt="删除" width="25px;" src="<c:url value='/static/img/imgs/img_del.png' />"></a>
								<div class="clear"></div>
							<div class="i_mini_label_1"></div>
							<div class="i_mini_label">证件号码：</div><b>
								${customer.certNrb }
							</b><div class="clear"></div>
								<div class="i_mini_label_1"></div>
								<div class="i_mini_label">旅客类型：</div><b>
								<c:choose>
									<c:when test="${customer.travelerType=='ADT' }">
										成人
									</c:when>
									<c:when test="${customer.travelerType=='CNN' }">
										儿童
									</c:when>
								</c:choose>
								</b><div class="clear"></div>
								<div class="i_mini_label_1"></div>
								<div class="i_mini_label">是否是网站同步：</div><b>
								<c:if test="${empty customer.synchronousStatus }">
									否
								</c:if>
								<c:if test="${!empty customer.synchronousStatus }">
									是
								</c:if>
							</b><div class="clear"></div>
						</div>
					</li>
				</c:forEach>
			</ul>
		</div>
		<div>
		<c:choose>
			<c:when test="${empty domestic }">
				<div><button class="btn" onclick="window.location.href='<c:url value='/member/inCommTakeInfo.do' />?odSerachId=${searchId }&odIndex=${index}&count=${count }&guestId=${guestId}&customerIds=${customerIds}&adultCount=${adultCount}&childCount=${childCount}'" data-theme="a" type="button">增加国内乘机人</button></div>
			</c:when>
			<c:when test="${domestic=='' }">
				<div><button class="btn" onclick="window.location.href='<c:url value='/member/inCommTakeInfo.do' />?odSerachId=${searchId }&odIndex=${index}&count=${count }&guestId=${guestId}&customerIds=${customerIds}&adultCount=${adultCount}&childCount=${childCount}'" data-theme="a" type="button">增加国内乘机人</button></div>
			</c:when>
			<c:when test="${domestic=='0' }">
				<div><button class="btn" onclick="window.location.href='<c:url value='/member/inCommOutTakeInfo.do' />?odSerachId=${searchId }&odIndex=${index}&count=${count }&guestId=${guestId}&customerIds=${customerIds}&domestic=${domestic}&destinationCountry=${destinationCountry}&adultCount=${adultCount}&childCount=${childCount}'" data-theme="a" type="button">增加国际乘机人</button></div>
			</c:when>
		</c:choose>
			<div class="f_bz">注：金卡及以上级别会员免费邮寄行程单</div>
		</div>
	</div>
</div>
</body>
</html>